#if !defined EDGEDDETECTOR
#define EDGEDDETECTOR

#include "cv.h"
#include "imageIterator.h"
#include <omp.h>

class EdgeDetector {

private:

	// private attributes
	IplImage *output;
	int thresh;

public:

	// empty constructor
	EdgeDetector() : output(0),thresh(50) { 

		// default parameter initialization here
	}

	// getters and setters


	IplImage* getOutputImage() {

		return output;
	}

	// to check if an initialization is required
	bool isInitialized(IplImage *image) {

		return output && (output->width == image->width) 
			&& (output->height == image->height);
	}

	// for all memory allocation
	void initialize(IplImage *image) {

		cvReleaseImage(&output);
		//output= cvCreateImage(cvSize(image->width,image->height),8, 1);
		output= cvCreateImage(cvSize(image->width,image->height),image->depth,image->nChannels);
	}

	// the processing of the image
	void process(IplImage *image);
	void processOpenMP(IplImage *image);

	// the method that checks for initialization
	// and then process the image
	inline void processImage(IplImage *image) {

		if (!isInitialized(image)) {

			initialize(image);
		}

		process(image);
	}
	inline void processImageOpenMP(IplImage *image) {

		if (!isInitialized(image)) {

			initialize(image);
		}

		processOpenMP(image);
	}

	// memory de-allocation
	void release() {

		cvReleaseImage(&output);
	}

	~EdgeDetector() {

		release();
	}
};

#endif
